// generation de la map via l'api google
var geocoder;
var map;
function initialize(address) {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(50.4662474,4.5367431);
    var options = {
        zoom: 12,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    map = new google.maps.Map(document.getElementById("map_canvas"), options);
    codeAddress(address);
}

function codeAddress(address) {
    if (geocoder) {
        geocoder.geocode( {
            'address': address
        }, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                    map: map,
                    position: results[0].geometry.location
                });
            } else {
                document.getElementById("map_canvas").value="Impossible de réaliser la géolocalisations";
            }
        });
    }
}


function getInsAteliers(id, idContact, typeIns, titre,rowNum) {

    jQuery(id).jqGrid({
        url:typeIns+'?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        altRows: true,
        scrollOffset: 1,
        width: 800,
        rowNum: rowNum,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Libelle','Type artistique','Animateur'],
        colModel:[
        {
            name:'Libelle',
            index:'Libelle'
        },

        {
            name:'Type artistique',
            index:'Type artistique'
        },

        {
            name:'Animateur',
            index:'Animateur'
        }
        ],
        caption: titre,
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../ins_atelier/"+rowid+"/show";
        }
    });
}


function getInsStages(id, idContact, typeIns, titre,rowNum) {

    jQuery(id).jqGrid({
        url:typeIns+'?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        altRows: true,
        scrollOffset: 1,
        width: 800,
        rowNum: rowNum,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Libelle','Type artistique','Animateur'],
        colModel:[
        {
            name:'Libelle',
            index:'Libelle'
        },

        {
            name:'Type artistique',
            index:'Type artistique'
        },

        {
            name:'Animateur',
            index:'Animateur'
        }
        ],
        caption: titre,
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../ins_stage/"+rowid+"/show";
        }
    });
}

function getReservations(id,idContact,rowNum) {
    jQuery(id).jqGrid({
        url:'contact_ins_reservation?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        altRows: true,
        scrollOffset: 1,
        rowNum: rowNum,
        width: 800,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Libelle','Date'],
        colModel:[
        {
            name:'Libelle',
            index:'Libelle'
        },

        {
            name:'Date',
            index:'Date'
        }
        ],
        caption: "Réservations",
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../reservation/"+rowid+"/show";
        }
    });
}

function getLocations(id,idContact,rowNum) {
    jQuery(id).jqGrid({
        url:'contact_ins_location?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        altRows: true,
        scrollOffset: 1,
        rowNum: rowNum,
        width: 800,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Libelle'],
        colModel:[
        {
            name:'Libelle',
            index:'Libelle'
        }
        ],
        caption: 'Locations',
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../location/"+rowid+"/show";
        }
    });
}

function getAbonnements(id,idContact,rowNum) {
    jQuery(id).jqGrid({
        url:'contact_ins_abonnement?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        altRows: true,
        scrollOffset: 1,
        rowNum: rowNum,
        width: 800,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Libelle','Saison'],
        colModel:[
        {
            name:'Libelle',
            index:'Libelle'
        },
        {
            name:'Saison',
            index:'Saison'
        }
        ],
        caption: 'Abonnements',
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../ins_abonnement/"+rowid+"/show";
        }
    });
}

function getNewsletters(id,idContact,rowNum) {
    jQuery(id).jqGrid({
        url:'contact_ins_newsletter?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        altRows: true,
        scrollOffset: 1,
        rowNum: rowNum,
        width: 800,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Libelle','Commentaire'],
        colModel:[
        {
            name:'Libelle',
            index:'Libelle'
        },

        {
            name:'Commentaire',
            index:'Commentaire'
        }
        ],
        caption: 'Newsletters',
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../newsletter/"+rowid+"/show";
        }
    });
}

function getCommunications(id,idContact,rowNum) {
    jQuery(id).jqGrid({
        url:'contact_ins_communication?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        altRows: true,
        width: 800,
        scrollOffset: 1,
        rowNum: rowNum,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Objet','Date','Commentaire'],
        colModel:[
        {
            name:'Objet',
            index:'Objet'
        },

        {
            name:'Date',
            index:'Date'
        },

        {
            name:'Commentaire',
            index:'Commentaire'
        }
        ],
        caption: 'Communications',
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../communication/"+rowid+"/show";
        }
    });
}

function getParrains(id,idContact,rowNum) {
    jQuery(id).jqGrid({
        url:'contact_ins_parrainage?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        width: 800,
        scrollOffset: 1,
        altRows: true,
        rowNum: rowNum,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Nom','Prénom'],
        colModel:[
        {
            name:'Nom',
            index:'Nom'
        },

        {
            name:'Prénom',
            index:'Prénom'
        }
        ],
        caption: 'Parrainage',
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "/"+rowid+"/show";
        }
    });
}

// toutes les listes
function getToutesInsStages(id, idContact) {
    jQuery(id).jqGrid({
        url:'contact_ins_stage?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        width: 800,
        scrollOffset: 1,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Libelle','Type artistique','Animateur'],
        colModel:[
        {
            name:'Libelle',
            index:'Libelle'
        },

        {
            name:'Type artistique',
            index:'Type artistique'
        },

        {
            name:'Animateur',
            index:'Animateur'
        }
        ],
        caption: "Stages",
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../ins_stage/"+rowid+"/show";
        }
    });
}

function getToutesInsAteliers(id,idContact) {
    jQuery(id).jqGrid({
        url:'contact_ins_atelier?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        width: 800,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Libelle','Type artistique','Animateur'],
        colModel:[
        {
            name:'Libelle',
            index:'Libelle'
        },

        {
            name:'Type artistique',
            index:'Type artistique'
        },

        {
            name:'Animateur',
            index:'Animateur'
        }
        ],
        caption: "Ateliers",
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../ins_atelier/"+rowid+"/show";
        }
    });
}

function getToutesCommunications(id, idContact) {
    jQuery(id).jqGrid({
        url:'contact_ins_communication?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        altRows: true,
        width: 800,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Objet','Date','Commentaire'],
        colModel:[
        {
            name:'Objet',
            index:'Objet'
        },

        {
            name:'Date',
            index:'Date'
        },

        {
            name:'Commentaire',
            index:'Commentaire'
        }
        ],
        caption: 'Communications',
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../communication/"+rowid+"/show";
        }
    });
}

function getToutesNewsletters(id, idContact) {
    jQuery(id).jqGrid({
        url:'contact_ins_newsletter?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        altRows: true,
        width: 800,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Libelle','Commentaire'],
        colModel:[
        {
            name:'Libelle',
            index:'Libelle'
        },

        {
            name:'Commentaire',
            index:'Commentaire'
        }
        ],
        caption: 'Newsletters',
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../newsletter/"+rowid+"/show";
        }
    });
}

function getToutesLocations(id, idContact) {
    jQuery(id).jqGrid({
        url:'contact_ins_location?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        altRows: true,
        width: 800,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Libelle'],
        colModel:[
        {
            name:'Libelle',
            index:'Libelle'
        }
        ],
        caption: 'Locations',
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../location/"+rowid+"/show";
        }
    });
}

function getToutesReservations(id, idContact) {
    jQuery(id).jqGrid({
        url:'contact_ins_reservation?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        altRows: true,
        width: 800,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Libelle','Date'],
        colModel:[
        {
            name:'Libelle',
            index:'Libelle'
        },

        {
            name:'Date',
            index:'Date'
        }
        ],
        caption: "Réservations",
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../reservation/"+rowid+"/show";
        }
    });
}

function getTousAbonnements(id,idContact) {
    jQuery(id).jqGrid({
        url:'contact_ins_abonnement?id='+idContact,
        datatype: "json",
        mtype:'GET',
        loadtext: "Chargement",
        altRows: true,
        scrollOffset: 1,
        width: 800,
        jsonReader : {
            root:"cellule"
        },
        emptyrecords: "Aucun enregistrement",
        colNames:['Libelle','Saison'],
        colModel:[
        {
            name:'Libelle',
            index:'Libelle'
        },
        {
            name:'Saison',
            index:'Saison'
        }
        ],
        caption: 'Abonnements',
        viewrecords: true,
        ondblClickRow: function (rowid, iRow, iCol, event) {
            location.href = "../abonnement/"+rowid+"/show";
        }
    });
}